package vo;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity
@NamedQueries({ 
	@NamedQuery(name = "User.findAll", query = "select u from User u"), 
	@NamedQuery(name = "User.findAllUserRole", query = "select u from User u where userGroup.role='user'"), 
	@NamedQuery(name = "User.findByName", query = "select u from User u where name=?"),
	@NamedQuery(name = "User.findByLoginName", query = "select u from User u where loginName=?"),
	@NamedQuery(name = "User.findByUsernamePSW", query = "select u from User u where loginName=? and password=?"),
    @NamedQuery(name = "User.findTotalCount", query = "select count(*) from User t")
	})
@Table(name = "user")
public class User extends BaseEntity {
	@Column(name = "name")
	private String name;

	@Column(name = "no")
	private String no;

	@Column(name = "department")
	String department;

	@Column(name = "email")
	String email;

	@JoinColumn(name = "group_id")
	@ManyToOne(fetch = FetchType.LAZY)
	private UserGroup userGroup;

	
	@Column(name = "lastLogin")
	Date lastLogin;

	@Column(name = "loginname")
	String loginName;

	@Column(name = "mobile")
	String mobile;

	@Column(name = "password")
	String password;

	@Column(name = "phone")
	String phone;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDepartment() {
		return department;
	}

	public void setDepartment(String department) {
		this.department = department;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}


	public UserGroup getUserGroup() {
		return userGroup;
	}

	public void setUserGroup(UserGroup userGroup) {
		this.userGroup = userGroup;
	}

	public Date getLastLogin() {
		return lastLogin;
	}

	public void setLastLogin(Date lastLogin) {
		this.lastLogin = lastLogin;
	}

	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getNo() {
		return no;
	}

	public void setNo(String no) {
		this.no = no;
	}

}
